<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<!-- 新 Bootstrap4 核心 CSS 文件 -->
<link rel="stylesheet" href="https://cdn.staticfile.org/twitter-bootstrap/4.3.1/css/bootstrap.min.css">

<!-- jQuery文件。务必在bootstrap.min.js 之前引入 -->
<script src="https://cdn.staticfile.org/jquery/3.2.1/jquery.min.js"></script>

<!-- bootstrap.bundle.min.js 用于弹窗、提示、下拉菜单，包含了 popper.min.js -->
<script src="https://cdn.staticfile.org/popper.js/1.15.0/umd/popper.min.js"></script>

<!-- 最新的 Bootstrap4 核心 JavaScript 文件 -->
<script src="https://cdn.staticfile.org/twitter-bootstrap/4.3.1/js/bootstrap.min.js"></script>
<head>
    <meta charset="UTF-8">
    <title>注册页面</title>

</head>
<body>
    <form th:action="@{/sys/user/register_mall}" method="post">

        <div class="card m-auto" style="width: 20rem" >
            <div class="card-body">
                <div class="input-group ">
                    <div class="input-group-prepend">
                        <span class="input-group-text text-primary" id="basic-addon1" >用户名</span>
                    </div>
                    <input type="text" id="userName" class="form-control" placeholder="请输入用户名" aria-label="Username" aria-describedby="basic-addon1" name="userName">
                </div>

                <div class="input-group mb-3">
                    <div class="input-group-prepend">
                        <span class="input-group-text text-primary" id="basic-addon2">密码</span>
                    </div>
                    <input type="password" class="form-control" id="password" placeholder="请输入密码" aria-label="Password" aria-describedby="basic-addon2" name="password">
                </div>

                <div class="input-group mb-3">
                    <div class="input-group-prepend">
                        <span class="input-group-text text-primary" id="basic-addon3">确认密码</span>
                    </div>
                    <input type="password" class="form-control" id="password2" placeholder="请输入密码" aria-label="Password" aria-describedby="basic-addon3" name="password2">
                </div>

                <div class="input-group mb-3">
                    <div class="input-group-prepend">
                        <span class="input-group-text text-primary" id="time">当前时间</span>
                    </div>
                    <span id="dateTime" name="createTime"></span>
                </div>

                <input type="submit" id="register_btn" class="btn btn-primary btn-lg btn-block" value="注册">
                <input type="reset" class="btn btn-primary btn-lg btn-block" value="Reset">
                <input type="submit" th:href="@{/sys/user/login}" id="login_btn" class="btn btn-primary btn-lg btn-block" value="登录">
            </div>
        </div>
    </form>
    <span th:text="${msg}"></span>


</body>
<script>
    Date.prototype.format = function (fmt) {
        var o = {
            "y+": this.getFullYear, //年
            "M+": this.getMonth() + 1, //月份
            "d+": this.getDate(), //日
            "h+": this.getHours(), //小时
            "m+": this.getMinutes(), //分
            "s+": this.getSeconds() //秒
        };
        if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
        for (var k in o)
            if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
        return fmt;
    }
    setInterval("document.getElementById('dateTime').innerHTML = (new Date()).format('yyyy-MM-dd hh:mm:ss');", 1000);

    $(function () {
        $("#register_btn").click(function () {
            var password=$("#password").val();
            var password2=$("#password2").val();
            var userName=$("userName").val();
            if(userName == '' || password == '' || password2 == ''){
                alert("用户名或密码不能为空");
            }else {
                if(password !=password2){
                    alert("密码不一致，请重新输入");
                }
            }
        })
    })
</script>
</html>